package protocol.JT808_2019;

import java.util.HashMap;

public class Handle808_2019JT10 implements IHandle808_2019JT {

    @Override
    public String handle(JT808_2019Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x01:
                return handle0101(cmd);
            default:
                return "808-2019:未匹配的命令字"+(cmd.readOrder()+","+cmd.subOrder());
        }
    }

    private String handle0101(JT808_2019Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("终端->平台:终端注册");
        builder.append("\r\n");
        builder.append("省域ID："+cmd.readInt(2));
        builder.append("\r\n");
        builder.append("市县域："+cmd.readInt(2));
        builder.append("\r\n");

        builder.append("制造商ID："+cmd.readBCD(11));
        builder.append("\r\n");
        builder.append("终端型号："+cmd.readBCD(30));
        builder.append("\r\n");
        builder.append("终端ID："+cmd.readBCD(30));
        builder.append("\r\n");
        builder.append("车牌颜色："+cmd.readBCD(1));
        builder.append("\r\n");
        builder.append("车牌："+cmd.readString(-1));
        builder.append("\r\n");


        return builder.toString();
    }
}
